package com.atao.baokede.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {
    @Value("${spring.elasticsearch.uris}")
    private String ES_SERVER_PATH;

    @Bean(destroyMethod = "close")
    public RestHighLevelClient setUp(){
         return new RestHighLevelClient(RestClient.builder(
                HttpHost.create(ES_SERVER_PATH)
        ));
    }

}